package cn.itsource.basic.controller;

import cn.itsource.basic.util.AjaxResult;
import cn.itsource.user.domain.User;
import cn.itsource.basic.service.IVerificationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
public class VerificationController {
    @Autowired
    private IVerificationService service;

    @PostMapping("/sendMobileCode")
    public AjaxResult getVerification(@RequestBody User user){
        try {
            service.sendVerificationCodeReg(user.getPhone());
            return  AjaxResult.me();
        } catch (Exception e) {
            e.printStackTrace();
            return new AjaxResult(false,e.getMessage());
        }
    }
    @PostMapping("/sendBinder")
    public AjaxResult sendBinder(@RequestBody User user){
        try {
            service.sendVerificationCodeBinder(user.getPhone());
            return  AjaxResult.me();
        } catch (Exception e) {
            e.printStackTrace();
            return new AjaxResult(false,e.getMessage());
        }
    }

}
